package com.jeespring.concurrent;

import org.openjdk.jol.info.ClassLayout;

import java.io.IOException;

/**
 * @Title: ClassLayout
 * @Description:
 * @Author 张朝阳
 * @Date 2021/1/9 15:10
 */
public class ClassLayoutExample {
    public static void main(String[] args) throws InterruptedException, IOException {

        // JVM启动的时候，偏向锁延迟4秒钟
        // JVM启动时，大量线程去竞争，没必要加偏向锁
        Thread.sleep(5000);
        Object object = new Object();
        System.out.println(ClassLayout.parseInstance(object).toPrintable());

        synchronized (object) {
            System.out.println(ClassLayout.parseInstance(object).toPrintable());
        }
    }
}
